export function getIconPieOption (data, color, config) {
  const opt = Object.assign({
    radius: [28, 30],
    center: ['50%', '50%'],
    icon: '',
    info: '',
    iconSize: 30,
    fontSize: 10
  }, config)
  const colorReMain = '#424466'
  const datalist = [{
    name: data.name,
    value: data.value,
    itemStyle: {
      color: color
    }
  }, {
    name: 'remain',
    value: 1 - data.value,
    itemStyle: {
      color: colorReMain
    }
  }]
  let option = {
    tooltip: { show: false, trigger: 'axis', axisPointer: { type: 'shadow' } },
    series: {
      type: 'pie',
      name: data.name,
      radius: opt.radius,
      center: opt.center,
      clockwise: false,
      roseType: opt.roseType,
      hoverAnimation: false,
      label: { show: false },
      data: datalist,
      markPoint: {
        data: [{
          symbol: opt.icon ? 'image://' + opt.icon : 'circle',
          symbolSize: opt.iconSize ? opt.iconSize : 0,
          name: 'icon',
          x: '50%',
          y: '50%',
          itemStyle: {
            color: 'transparent'
          },
          value: data.value,
          label: {
            normal: {
              show: !opt.icon,
              fontSize: 24,
              color: '#0CF6B9',
              formatter (params) {
                return Math.round(params.value * 100) + '%'
              }
            }
          }
        }]
      }
    }
  }
  if (opt.formatTooltip) {
    option.tooltip = opt.formatTooltip
  }
  return option
}
